package cn.ycc1.myupper.model;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.StreamingChatModel;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author ycc
 * @date 2025/5/6
 */
@RestController
public class StreamDeepSeekController {
    private final StreamingChatModel chatModel;

    public StreamDeepSeekController(StreamingChatModel chatModel) {
        this.chatModel = chatModel;
    }

    @GetMapping(value = "/deepseek/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> streamResponse(@RequestParam String message) {
        return chatModel.stream(message);
    }
}
